#include "frame.h"
#include <stdlib.h>
#include <stdio.h>
int main() 
{
frame* sp = NULL;
sp = (frame*)malloc(sizeof(frame));
frame* fp = sp;
sp->return_address = 0;
sp->parent = NULL;
sp->master = NULL;
frame* sp_aux = sp;
//return address
int _ra;
int register_counter = 32;
//return value
var *_rv;
//extra registers
var *_rx[register_counter];
var _AX;
var _BX;
sp->locals = (var*)malloc(1*sizeof(var*));
//**CallBlock**//
fp = sp;
sp = (frame*)malloc(sizeof(frame));
sp->master = NULL;
if(fp->master==NULL) 
	sp->master = fp;
sp->locals = (var*)malloc(1*sizeof(var));
_rv = (var*)malloc(sizeof(var));
_rv->type = v_integer;
_rv->value.integer=2;
if( _rv->type == v_integer) 
 	sp->locals[0].value.integer = _rv->value.integer; 
if( _rv->type == v_float) 
 	sp->locals[0].value.real = _rv->value.real; 
if( _rv->type == v_string) 
 	sp->locals[0].value.string = _rv->value.string; 
if( _rv->type == v_boolean) 
 	sp->locals[0].value.boolean = _rv->value.boolean; 
sp->locals[0].type = _rv->type;
goto teste;
return1 :
_ra = sp->return_address;
sp = sp->parent;
fp = sp->parent;
goto teste_skip;
teste :
sp_aux = sp;
_rv = (var*)malloc(sizeof(var));
if( sp_aux->locals[0].type == v_integer)
	_rv->value.integer = sp_aux->locals[0].value.integer; 
if( sp_aux->locals[0].type == v_string)
	_rv->value.string = sp_aux->locals[0].value.string; 
if( sp_aux->locals[0].type == v_float)
	_rv->value.real = sp_aux->locals[0].value.real; 
if( sp_aux->locals[0].type == v_boolean)
	_rv->value.boolean = sp_aux->locals[0].value.boolean; 
_rv->type = sp_aux->locals[0].type;
if( _rv->type == v_integer)
	sp_aux->locals[1].value.integer = _rv->value.integer; 
if( _rv->type == v_string)
	sp_aux->locals[1].value.string = _rv->value.string; 
if( _rv->type == v_float)
	sp_aux->locals[1].value.real = _rv->value.real;
if( _rv->type == v_boolean)
	sp_aux->locals[1].value.boolean = _rv->value.boolean; 
sp_aux->locals[1].type = _rv->type;
_rv = (var*)malloc(sizeof(var));
if( sp_aux->locals[1].type == v_integer)
	_rv->value.integer = sp_aux->locals[1].value.integer; 
if( sp_aux->locals[1].type == v_string)
	_rv->value.string = sp_aux->locals[1].value.string; 
if( sp_aux->locals[1].type == v_float)
	_rv->value.real = sp_aux->locals[1].value.real; 
if( sp_aux->locals[1].type == v_boolean)
	_rv->value.boolean = sp_aux->locals[1].value.boolean; 
_rv->type = sp_aux->locals[1].type;
if(_rv->type == v_integer) printf(" %d ", _rv->value.integer);
if(_rv->type == v_float) printf(" %f ", _rv->value.real);
if(_rv->type == v_string) printf(" %s ", _rv->value.string);
if(_rv->type == v_boolean) printf(" %d ", _rv->value.boolean);
sp_aux = sp->parent;
_ra = sp->return_address;
goto redirector;
teste_skip :
redirector:
if(_ra == 1) goto return1;
return 0;
}
